using System;
namespace MicroMsg.Network
{
	public class Queue
	{
		public ListNode _head;
		public ListNode _tail;
		public int _size;
		public Queue()
		{
			this._head = new ListNode(null, 0);
			this._tail = this._head;
			this._size = 0;
		}
		public bool remove(int int_0)
		{
			if (this._size == 0)
			{
				return false;
			}
			ListNode next = this._head._next;
			ListNode listNode = this._head;
			while (next != null)
			{
				if (next._id == int_0)
				{
					listNode._next = next._next;
					this._size--;
					if (next._next == null)
					{
						this._tail = listNode;
					}
					return true;
				}
				listNode = next;
				next = next._next;
			}
			return false;
		}
		public void changeID(int int_0, int newid)
		{
			if (this._size == 0)
			{
				return;
			}
			for (ListNode next = this._head._next; next != null; next = next._next)
			{
				if (next._id == int_0)
				{
					next._id = newid;
					return;
				}
			}
		}
		public object method_0(int int_0)
		{
			if (this._size == 0)
			{
				return null;
			}
			for (ListNode next = this._head._next; next != null; next = next._next)
			{
				if (next._id == int_0)
				{
					return next._obj;
				}
			}
			return null;
		}
		public void putToTail(object object_0, int int_0)
		{
			this._tail._next = new ListNode(object_0, int_0);
			this._tail = this._tail._next;
			this._size++;
		}
		public void putToHead(object object_0, int int_0)
		{
			ListNode listNode = new ListNode(null, 0);
			this._head._obj = object_0;
			this._head._id = int_0;
			listNode._next = this._head;
			this._head = listNode;
			this._size++;
		}
		public void moveToTail(int int_0)
		{
			if (this._size < 2)
			{
				return;
			}
			ListNode listNode = this._head;
			for (ListNode next = this._head._next; next != null; next = next._next)
			{
				if (next._id == int_0 && next._id != this._tail._id)
				{
					listNode._next = next._next;
					next._next = null;
					this._tail._next = next;
					this._tail = this._tail._next;
					return;
				}
				listNode = next;
			}
		}
		public bool isEmpty()
		{
			return this._size == 0;
		}
		public int size()
		{
			return this._size;
		}
		public void reset()
		{
			this._head._next = null;
			this._tail = this._head;
			this._size = 0;
		}
	}
}
